package com.example.ppjoke;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.blankj.utilcode.util.ToastUtils;
import com.example.adapter_sdk.quick.BaseQuickAdapter;
import com.example.adapter_sdk.quick.BaseQuickMoreAdapter;

import java.util.ArrayList;
import java.util.List;

import static com.blankj.utilcode.util.CrashUtils.init;


public class MoreActivity extends AppCompatActivity   {
    private RecyclerView more_rv;
    private MoreAdapter adapter;
    private List<MoreEntity> list = new ArrayList<>();
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_more);
        init();
        initData();
        adapter.setNewInstance(list);
    }
    private void init(){
        more_rv = findViewById(R.id.more_rv);
        LinearLayoutManager manager = new LinearLayoutManager(this);
        manager.setOrientation(LinearLayoutManager.VERTICAL);
        more_rv.setLayoutManager(manager);
        adapter = new MoreAdapter();
        adapter.setOnItemChildClickListener(new BaseQuickMoreAdapter.OnItemChildClickListener() {
            @Override
            public void onItemChildClick(RecyclerView.Adapter adapter, int id, int position) {
                if (id==R.id.more_title_tv){
                    ToastUtils.showShort("=======more_title_tv"+id+","+position);
                }
                if (id==R.id.more_value_tv){
                    ToastUtils.showShort("=======more_value_tv"+id+","+position);
                }
            }
        });
//        adapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
//            @Override
//            public void onItemChildClick(RecyclerView.Adapter adapter, int id, int position) {
//                if (id==R.id.more_title_tv){
//                    ToastUtils.showShort("====title"+position);
//                }
//                if (id==R.id.more_value_tv){
//                    ToastUtils.showShort("====图片"+position);
//                }
//            }
//        });
        more_rv.setAdapter(adapter);
    }
    private void initData(){
        for (int i = 0;i < 30;i ++){
            list.add(new MoreEntity("title:"+i,"value:"+i,(i%2>0?1:0)));
        }

    }

}
